package team.southcat.wsyygh.common.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import team.southcat.wsyygh.common.result.Result;

/**
 * 全局异常处理
 */
@ControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(WsyyghException.class)
    @ResponseBody
    public Result wsyyghExceptionHandler(WsyyghException e){
        System.out.println("业务错误！！！" + e.getMessage());
        e.printStackTrace();
        return Result.fail().message(e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e){
        e.printStackTrace();
        return Result.fail().message("数据错误");
    }



}
